package de.hauschild.gmltracer.gml.impl.value.bool;

import de.hauschild.gmltracer.gml.Environment;
import de.hauschild.gmltracer.gml.TokenStack;
import de.hauschild.gmltracer.gml.impl.AbstractToken;
import de.hauschild.gmltracer.gml.impl.value.integer.IntegerToken;

public abstract class TwoIntegerComparatorToken extends AbstractToken {

  @Override
  public void evaluate(final Environment environment, final TokenStack tokenStack) {
    final IntegerToken second = tokenStack.pop(IntegerToken.class);
    final IntegerToken first = tokenStack.pop(IntegerToken.class);

    final Boolean result = compare(first.getValue(), second.getValue());
    tokenStack.push(new BooleanToken(result));
  }

  protected abstract boolean compare(final Integer first, final Integer second);

}
